﻿namespace TVersityDotNet.MediaLib
{
    using System.Collections.ObjectModel;
    using System.Runtime.Serialization;

    [DataContractAttribute]
    public struct SearchClassTypeName
    {
        [DataMember]
        public const string VideoItem = "object.item.videoItem";
        [DataMember]
        public const string MusicItem = "object.item.audioItem.musicTrack";
        [DataMember]
        public const string MusicArtist = "object.container.person.musicArtist";
        [DataMember]
        public const string People = "object.container.person";
        [DataMember]
        public const string Photo = "object.item.imageItem.photo";
        [DataMember]
        public const string MediaItem = "object.item";
        [DataMember]
        public const string Container = "object.container";
        [DataMember]
        public const string Folder = "object.container.storageFolder";
        [DataMember]
        public const string NoClass = "noclass";

        /// <summary>
        /// Static method used to get the name of a <see cref="MediaLibClassType"/>
        /// </summary>
        /// <param name="type">The SearchClassType</param>
        /// <returns>The name of the searchclasstype</returns>
        public static string GetNameBySearchClassType(MediaLibClassType type)
        {
            switch (type)
            {
                case MediaLibClassType.MediaItem:
                    return MediaItem;
                case MediaLibClassType.MusicArtist:
                    return MusicArtist;
                case MediaLibClassType.MusicItem:
                    return MusicItem;
                case MediaLibClassType.NoClass:
                    return NoClass;
                case MediaLibClassType.People:
                    return People;
                case MediaLibClassType.Photo:
                    return Photo;
                case MediaLibClassType.VideoItem:
                    return VideoItem;
                case MediaLibClassType.Container:
                    return Container;
                case MediaLibClassType.Folder:
                    return Folder;
                default:
                    return NoClass;
            }
        }

        /// <summary>
        /// Static method used to get the name of a <see cref="MediaLibClassType"/>
        /// </summary>
        /// <param name="type">The SearchClassType</param>
        /// <returns>The name of the searchclasstype</returns>
        public static MediaLibClassType GetTypeBySearchClassName(string name)
        {
            switch (name)
            {
                case MediaItem:
                    return MediaLibClassType.MediaItem;
                case MusicArtist:
                    return MediaLibClassType.MusicArtist;
                case MusicItem:
                    return MediaLibClassType.MusicItem;
                case NoClass:
                    return MediaLibClassType.NoClass;
                case People:
                    return MediaLibClassType.People;
                case Photo:
                    return MediaLibClassType.Photo;
                case VideoItem:
                    return MediaLibClassType.VideoItem;
                case Container:
                    return MediaLibClassType.Container;
                case Folder:
                    return MediaLibClassType.Folder;
                default:
                    return MediaLibClassType.NoClass;
            }
        }

        /// <summary>
        /// Returns the list of all possible names
        /// </summary>
        public static Collection<string> ListOfNames
        {
            get
            {
                var returnList = new Collection<string>();
                returnList.Add(SearchClassTypeName.VideoItem);
                returnList.Add(SearchClassTypeName.MusicItem);
                returnList.Add(SearchClassTypeName.MediaItem);
                returnList.Add(SearchClassTypeName.MusicArtist);
                returnList.Add(SearchClassTypeName.People);
                returnList.Add(SearchClassTypeName.Photo);
                returnList.Add(SearchClassTypeName.Container);
                returnList.Add(SearchClassTypeName.Folder);
                return returnList;
            }

        }
    }

    [DataContractAttribute]
    public enum MediaLibClassType
    {
        [EnumMember]
        VideoItem,
        [EnumMember]
        MusicItem,
        [EnumMember]
        MusicArtist,
        [EnumMember]
        People,
        [EnumMember]
        Photo,
        [EnumMember]
        MediaItem,
        [EnumMember]
        Container,
        [EnumMember]
        Folder,
        [EnumMember]
        NoClass
    }
}
